﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenericList
{
    class Program
    {
        static void Main(string[] args)
        {
            GenericList<int> intList = new GenericList<int>();
            for(int i = 0; i < 10; i++)
            {
                intList.Add(i);
            }
            int min=intList.Head.Data, max= intList.Head.Data, sum = 0;
            Action<int> action = m => {
                Console.WriteLine(m);
                if (m < min) { min = m; }
                if (m > max) { max = m; }
                sum += m;
            };
            GenericList<int>.ForEach(intList,action);
            Console.WriteLine(min);
            Console.WriteLine(max);
            Console.WriteLine(sum);

            GenericList<Student> studentList = new GenericList<Student>();
            for(int i = 0; i < 10; i++)
            {
                studentList.Add(new Student(i));
            }
            min =max= studentList.Head.Data.age;
            sum = 0;
            Action<Student> action1 = m => {
                Console.WriteLine(m.age);
                if (m.age < min) { min = m.age; }
                if (m.age > max) { max = m.age; }
                sum += m.age;
            };
            GenericList<Student>.ForEach(studentList, action1);
            Console.WriteLine(min);
            Console.WriteLine(max);
            Console.WriteLine(sum);
            Console.ReadKey();
        }
    }
}
